//
//  FANUserAccount.m
//  Weibo - OC
//
//  Created by user on 16/4/19.
//  Copyright © 2016年 user. All rights reserved.
//

#import "FANUserAccount.h"

@implementation FANUserAccount

+ (instancetype)modelWithDict:(NSDictionary *)dict{
    
    FANUserAccount *model = [[FANUserAccount alloc] init];
    
    [model setValuesForKeysWithDictionary:dict];
    
    return model;
}

- (void)setExpires_in:(double)expires_in{
    
    self.expiresDate = [[NSDate alloc] initWithTimeIntervalSinceNow:expires_in];
}

/*
 @property (nonatomic, copy) NSString *access_token;
 
 @property (nonatomic, copy) NSString *remind_in;
 
 @property (nonatomic, copy) NSString *uid;
 
 @property (nonatomic, copy) NSString *name;
 
 @property (nonatomic, copy) NSString *avatar_large;
 
 @property (nonatomic, assign) double expires_in;
 */

//存档
- (void)encodeWithCoder:(NSCoder *)aCoder{
    
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.remind_in forKey:@"remind_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.avatar_large forKey:@"avatar_large"];
    [aCoder encodeDouble:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.expiresDate forKey:@"expiresDate"];

}

//解档
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
    
    self = [super init];
    
    if (self !=  nil){
        
        self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.remind_in = [aDecoder decodeObjectForKey:@"remind_in"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.avatar_large = [aDecoder decodeObjectForKey:@"avatar_large"];
        self.expires_in = [aDecoder decodeDoubleForKey:@"expires_in"];
        self.expiresDate = [aDecoder decodeObjectForKey:@"expiresDate"];
        
    }
        
    

    
    return self;
}


@end
